window.onload = function() {

    var columns = [
        { field: 'menuId', title: 'id', align: "center", width: "20%" },
        { field: 'menuName', title: '菜单名称', align: "center" },
        { field: 'menuLevel', title: '菜单层级', align: "center", width: "10%" },
        { field: 'remark', title: '备注', align: "center" },
        { field: 'status', title: '状态', align: "center", visible: false }
    ]
    tableData = {
        initData: function() {
            $('#table').bootstrapTable({
                method: 'get',
                contentType: 'application/json',
                url: "/operation/system/menu/",
                dataField: "data",
                pageNumber: 1,
                uniqueId: "menuId",
                pagination: true,
                escape: true,
                cache: false,
                queryParams: function(params) {
                    return {
                        pageSize: params.limit,
                        page: params.offset / params.limit + 1,
                        search: $("#searchVal").val()
                    }
                },
                sidePagination: 'server',
                pageSize: 10,
                pageList: [10, 20, 50],
                responseHandler: function(result) {
                    var errcode = result.message;
                    if (errcode == "成功") {

                        return {
                            total: result.data.conf.totalNum,
                            data: result.data.list
                        };
                    } else {
                        alert("错误代码" + errcode);
                        return;
                    }
                },
                paginationPreText: "上一页",
                paginationNextText: "下一页",
                showHeader: true,
                columns: columns,
                onClickRow: function(row, $element) {
                    defaultParams = row
                    $($element).addClass("changeColor").siblings().removeClass("changeColor")

                },
                onDblClickRow: function(data) {
                    modify('menu')
                }

            });
        }
    }

    tableData.initData()

}
